

var types='w'
var r=''
	function getLoginUser(json)
	{		//undefined

	if(typeof(json)=='undefined'){
		window.webkit.messageHandlers.toLogin.postMessage(null);//拉取登录
	}
	else{

		//checkuser();
		r=json
	
	}//

}

$('#btn01').click(function(){
	
	var temp=sessionStorage.getItem('clbnb')
	
	
	if(types=='w')
	{
			if(temp==null)
			{
			   $('.btn01').attr('href','login.html')
			}
			else
			{
				$('.btn01').attr('href','message.html') 
			}
	}
	else{
	

		let obj = eval('(' + r + ')');
		var userinfo=obj
	
		$.ajax({
			type: "post",
			url: url+'/app/blog/getUserExpend?userid='+userinfo.id,
			 dataType: "json",
			 //jsonp: "jsoncallback",
			 success: function (json) {
			
				if(json.code==1104)
				{
					tm='{"tel":"'+userinfo.account+'","state":1104,"userid":"'+userinfo.id+'"}'
					sessionStorage.setItem('clbnb',tm)
					window.location.href='sm.html'
				}
				else
				{
					tm='{"tel":"'+userinfo.account+'","state":1105,"userid":"'+userinfo.id+'"}'
					sessionStorage.setItem('clbnb',tm)
					window.location.href='message.html?id=11'
				}
			 },
			 error: function (err) {
				 console.log(err)
			 }
		 });
	}



})
function getUser() {
    //return imagelistener.getLoginUser()
    return imagelistener.toLogin()
}

function getDeviceId(e)//ios
{
    if(e!='')
    {
        types='a'
        $('.btn_back').hide()
        $('.btn_back2').hide()
        $('.btn_back3').hide()
    }
    else{       
    } 
}

function LoginResult(e){

}
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //判断iPhone|iPad|iPod|iOS

         
  } else if (/(Android)/i.test(navigator.userAgent)) {  //判断Android
    //alert(navigator.userAgent); 

  } else { //pc

  };


var url='https://www.cailianxinwen.com'
var pagenumber=1
var stitle=''
$('.btn_ss').click(function(){
    $('.mask').show()
    document.body.style.overflow='hidden'
})
$('#close').click(function(){
    document.body.style.overflow='visible'
    $('.mask').hide()
})
var typelist=['','求助','咨询','建言','投诉','感谢']
getlist(1,'')

function getlist(pagenumber,title){

    var _html=''
    $.ajax({
        type: "post",
        url: url+'/app/blog/getBlogDetailList?pagenow='+pagenumber+'&title='+title,
         dataType: "json",
         //jsonp: "jsoncallback",
         success: function (json) {
             console.log(json)
             if(pagenumber==1)
             {       
                $.each(json.list, function(index, value) {
                    _html+='<a href="listshow.html?id='+value.id+'&types='+types+'"><li>'
                    _html+='<div class="float_left num">'+(index+1)+'</div>'
                    _html+='<div class="float_left con">'
                    _html+='<h3><span class="hot">'+typelist[value.type]+'</span>&nbsp;|&nbsp;'+value.title+'</h3>'
                    _html+='<h5>'+value.posttime+'</h5>'
                    _html+='</div><div class="clear"></div>'
                    _html+='</li></a>'
            
                        
                  });
                  $('.listbox').html(_html)
                  $('.num').first().removeClass('num').addClass('num01')
                  $('.num').first().removeClass('num').addClass('num02')
                  $('.num').first().removeClass('num').addClass('num03')
             }
             else{
                $.each(json.list, function(index, value) {
                    _html+='<a href="listshow.html?id='+value.id+'"><li>'
                    _html+='<div class="float_left num">'+(8*(pagenumber-1)+index+1)+'</div>'
                    _html+='<div class="float_left con">'
                    _html+='<h3><span class="hot">'+typelist[value.type]+'</span>&nbsp;|&nbsp;'+value.title+'</h3>'
                    _html+='<h5>'+value.posttime+'</h5>'
                    _html+='</div><div class="clear"></div>'
                    _html+='</li></a>'
                        
                  });
                  $('.listbox').append(_html)
             }
           
         },
         error: function (err) {
             console.log(err)
         }
     });
}
function getLoginUser(json)
{
    //ios
    if (json==null || json=='' || typeof(json)==null)
    {
        window.webkit.messageHandlers.toLogin.postMessage(null);//拉取登录
    }
  r=  json


}
function LoginResult(e){
    //getLoginUser()
      $('body').html(r)
 }
 
typeselect()
function typeselect(){
    _html=''
    _html1=''
    _ul1='<ul>'
    _ul2='</ul>'
    $.ajax({
        type: "post",
        url: url+'/app/blog/getFieldList',
         dataType: "json",
         //jsonp: "jsoncallback",
         success: function (json) {
           
            //tab-menu
            $.each(json, function(index, value) {
                _html+="<li cid="+value.id+">"+value.name+"</li>"  
                _html1+=_ul1
                $.each(value.c_list, function(index, value1) {

                    _html1+='<li id="'+value1.id+'">'+value1.name+'</li>'
                })
                _html1+=_ul2

              });
              $('.tab-menu ul').html(_html)
              $('.tab-menu ul li').first().attr('id','a')
              $('.tab-box').html(_html1)
         },
         error: function (err) {
             console.log(err)
         }
     });
}

$(document).scroll(function() {

    // 判断是否滚动到页面底部
    if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
        pagenumber++
        getlist(pagenumber,stitle)
    }
  });

  $('#searchbtn').click(function(){
    var t=$('#searchinput').val()
    stitle=t
    getlist(1,t)


  })
